@import "./vars.scss";
@import "./mixins.scss";
// @import "./icon.scss?import";
@import "./icon.scss";

.drag-svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}

.drag-layout {
  @include flex;
  justify-content: center;
  background: #f7f8f9;
  height: 100%;
  min-width: 1400px;
  overflow: hidden;
  * {
    box-sizing: border-box;
  }
  button {
    display: inline-block;
    line-height: 1;
    cursor: pointer;
    background: #fff;
    border: none;
    -webkit-appearance: none;
    text-align: center;
    outline: 0;
    transition: all 0.2s ease;
    font-weight: 500;
    user-select: none;
    margin: 0;
    font-size: 14px;
  }

  &__left,
  &__content,
  &__right {
    height: 100%;
  }
  &__left,
  &__right {
    width: 400px;
    background: #fff;
    overflow: auto;
  }
  // 左侧布局
  &__left {
    overflow: hidden;
    @include flex;
    box-shadow: 0 2px 6px 0px $--drag-shadow-color;
    z-index: 10;
    *::-webkit-scrollbar {
      display: none;
    }
    .components-title {
      height: 100%;
      overflow: hidden auto;
      width: 120px;
      text-align: center;
      padding: 8px;
      box-shadow: 0 2px 6px 0px rgba(65, 77, 96, 0.08);
      @include flex;
      flex-direction: column;

      button {
        border-radius: 60px;
        margin-bottom: 8px;
        padding: 10px 20px;
        transition: all 0.3s ease;
        color: #606266;

        &.active {
          background-color: $--drag-background-color;
          color: $--drag-primary;
          transition: all 0.3s ease;
        }
        &:hover {
          transition: all 0.3s ease;
        }
        &:not(.active):hover {
          color: $--drag-primary;
          background-color: $--drag-background-hover-color;
        }
      }
    }

    .components-content {
      flex: 1;
      padding: 20px;
      overflow: hidden auto;
      .widget-title {
        margin: 0;
      }
      .widget-box {
        width: 100%;
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #333;
        border: 1px solid #fff;
        text-align: center;
        box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.2);
        user-select: none;
        cursor: move;
        border-radius: 4px;
        margin: 20px 0;
        transition: all 0.2s ease;
        &.disdraggable {
          cursor: no-drop;
        }
        &:hover {
          color: $--drag-primary;
          box-shadow: 0 0 6px 3px $--drag-primary-alpha;
        }
        img {
          vertical-align: middle;
        }
      }
    }
  }
  // 中间布局
  &__content {
    flex: 1;
    position: relative;
    @include flex(column);
    &--toolbar {
      min-height: 34px;
      background-color: #fff;
      box-shadow: 0 2px 6px -2px $--drag-shadow-color;
      z-index: 10;
      padding: 0 10px;
      @include flex;
      justify-content: flex-end;
      align-items: center;
      .toolbar-btn {
        color: $--drag-primary;
        padding: 10px 5px;
        margin: 0 5px;
      }
    }
    *::-webkit-scrollbar {
      display: none;
    }
    .viewer-wrapper {
      flex: 1;
      overflow: auto;
    }
    .editor-main {
      margin: 40px auto 0;
      width: 375px;
      background-color: #fff;
      box-shadow: 0 2px 6px $--drag-shadow-color;
      user-select: none;
      // overflow: hidden;
      border-radius: 3px;
      position: relative;

      &:before {
        border-top: 1px dashed rgba(0, 0, 0, 0.3);
        color: rgba(0, 0, 0, 0.3);
        content: "主流机型高度";
        font-size: 12px;
        left: -80px;
        position: absolute;
        top: 695px;
      }
      // 视图导航
      .viewer-nav {
        overflow: hidden;
        height: 55px;
        transition: all 0.3s;
        cursor: pointer;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        // position: sticky;
        // top: 0;
        // z-index: 99;
        // background-color: #fff;
        &:hover {
          transform: scale(0.98);
          border-radius: 5px;
          overflow: hidden;
          box-shadow: 0 0 10px #afafaf;
        }
        &__statusbar,
        &__title {
          text-align: center;
        }
        // 状态栏
        &__statusbar {
          font-size: 12px;
          height: 20px;
          line-height: 20px;
          color: #666;
        }
        // 页面标题
        &__title {
          height: 35px;
          line-height: 35px;
          font-size: 14px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          padding: 0 10px;
        }
      }
      // 视图区域
      .viewer-body {
        position: relative;
        background-size: cover;
        background-repeat: repeat;
        background-position: 50% 0;

        &__mask {
          background: hsla(0, 0%, 100%, 0.8);
          height: 100%;
          position: absolute;
          width: 100%;
        }
        &__empty {
          font-size: 14px;
          color: rgba(0, 0, 0, 0.3);
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          z-index: 9;
        }
        > .viewer-main {
          min-height: 640px;
          position: relative;
          z-index: 10;
        }
      }
      // 拖拽移动时
      .widget-box.ghost {
        @include drag;
      }
      // 在widget展示视图中
      .viewer-item {
        position: relative;
        outline-offset: 0;
        outline: 1px dashed transparent;
        background-color: rgba(236, 245, 255, 0.3);
        margin: 1px 0;
        transition: all 0.25s ease;
        cursor: move;

        &:first-child {
          margin-top: 1px;
        }
        &__default {
          text-align: center;
          color: #666;
          font-size: 14px;
        }
        &__action,
        &__drag {
          position: absolute;
          z-index: 10;

          i {
            font-size: 14px;
            color: #fff;
            margin: 0 5px;
          }
        }
        // 复制/删除区域
        &__action {
          top: 0;
          right: -34px;
          @include flex(column);
          align-items: center;

          &--btn {
            width: 28px;
            height: 28px;
            line-height: 28px;
            cursor: pointer;
            background-color: #fff;
            border-radius: 2px;
            @include flex(column);
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 6px 0 $--drag-shadow-color;
            &:not(:last-child) {
              margin-bottom: 4px;
            }
          }
          .dragicon {
            color: #828b9f;
          }
        }
        // 移动小图标
        &__drag {
          height: 28px;
          line-height: 28px;
          right: -1px;
          top: -1px;
          // display: none;
          i {
            cursor: move;
          }
        }

        &:after {
          position: absolute;
          left: 0;
          right: 0;
          top: 0;
          bottom: 0;
          display: block;
        }

        &:hover {
          outline-color: $--drag-primary;
          &.active:not(.ghost) {
            outline: 1px solid $--drag-primary;
          }

          .viewer-item__drag {
            display: block;
          }
        }

        // 选中状态
        &.active {
          outline: 1px solid $--drag-primary;
        }

        // 拖拽移动时
        &.ghost {
          @include drag;
        }
      }
    }
  }
  &__right {
    z-index: 10;
    width: 450px;
    box-shadow: 0 -2px 6px 0px $--drag-shadow-color;
  }
}
